package com.cv.platform.controller.platform.collection.vo;

import com.cv.framework.common.pojo.PageResult;
import com.cv.framework.common.pojo.Result;
import com.cv.platform.controller.platform.collection.vo.collection.*;
import com.cv.platform.service.collection.CvVideoCollectionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

import static com.cv.framework.common.pojo.Result.success;

/**
 * 视频平台 - 视频合集控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 视频合集控制层")
@RestController
@RequestMapping("/platform/video/collection")
public class CvVideoCollectionController {

    @Resource
    private CvVideoCollectionService cvVideoCollectionService;

    @PostMapping("create")
    @Operation(summary = "新增视频合集")
    public Result<Long> createCollection(@RequestBody CvVideoCollectionSaveReqVO reqVO) {
        return success(cvVideoCollectionService.createCollection(reqVO));
    }

    @PutMapping("update")
    @Operation(summary = "修改视频合集")
    public Result<Long> updateCollection(@RequestBody CvVideoCollectionSaveReqVO reqVO) {
        return success(cvVideoCollectionService.updateCollection(reqVO));
    }

    @DeleteMapping("delete")
    @Operation(summary = "删除视频合集")
    public Result<Void> deleteCollection(Long id) {
        cvVideoCollectionService.deleteCollection(id);
        return success();
    }

    @GetMapping("page")
    @Operation(summary = "分页查询视频合集")
    @PermitAll
    public Result<PageResult<CvVideoCollectionRespVO>> page(CvVideoCollectionPageReqVO reqVO) {
        return success(cvVideoCollectionService.getCollectionPage(reqVO));
    }

    @GetMapping("detail")
    @Operation(summary = "获取视频合集详情")
    @PermitAll
    public Result<CvVideoCollectionDetailRespVO> detail(CvVideoCollectionDetailPageReqVO reqVO) {
        return success(cvVideoCollectionService.getCollection(reqVO));
    }

}
